package design_pattern.ActiveObjects;

/**
 * @Author: 蔡翔
 * @Date: 2019/11/27 15:55
 * @Version 1.0
 */
public class SchedualerThread extends Thread {
    private final ActivationQueue activationQueue;

    public SchedualerThread(ActivationQueue activationQueue){
        this.activationQueue = activationQueue;
    }

    public void invoke(MethodRequest request){
        this.activationQueue.put(request);
    }

    @Override
    public void run() {
        while (true){
            // 定期的从 activationQueue里面拿出一条数据去执行。
            activationQueue.take().execute();
        }
    }
}
